#include "Main.h"

cMultiboard::cMultiboard()
{
	this->dwId = NULL;
}

cMultiboard::~cMultiboard()
{
	this->DestroyMultiboard();
}

DWORD cMultiboard::CreateMultiboard()
{
	if(this->dwId)
		this->DestroyMultiboard();

	this->dwId = GAME_CreateMultiboard();
	
	return this->dwId;
}

VOID cMultiboard::SetMultiboardColumns(DWORD dwColumns)
{
	if(this->dwId)
		GAME_SetMultiboardColumns(this->dwId, dwColumns);
}

VOID cMultiboard::SetMultiboardRows(DWORD dwRows)
{
	if(this->dwId)
		GAME_SetMultiboardRows(this->dwId, dwRows);
}

VOID cMultiboard::DestroyMultiboard()
{
	if(this->dwId)
		GAME_DestroyMultiboard(this->dwId);

	this->dwId = NULL;
}

VOID cMultiboard::SetMultiboardTitle(CHAR* szTitle)
{
	if(!this->dwId)
		return;

	Multiboard* pBoard = GAME_GetMultiboard(this->dwId);

	if(pBoard)
		GAME_SetMultiboardTitle(pBoard, NULL, szTitle);
}

VOID cMultiboard::SetItemIcon(CHAR* szPath, DWORD dwColumn, DWORD dwRow)
{
	if(!this->dwId)
		return;

	DWORD dwItemId = GAME_GetMultiboardItemId(this->dwId, dwColumn, dwRow);

	if(dwItemId)
	{
		MultiboardItem* pItem = GAME_GetMultiboardItem(dwItemId);

		if(pItem)
			GAME_SetMultiboardItemIcon(pItem, NULL, szPath);
	}

	GAME_ReleaseMultiboardItemId(dwItemId);
}

VOID cMultiboard::SetItemValue(CHAR* szValue, DWORD dwColumn, DWORD dwRow)
{
	if(!this->dwId || !szValue)
		return;

	DWORD dwItemId = GAME_GetMultiboardItemId(this->dwId, dwColumn, dwRow);

	if(dwItemId)
	{
		MultiboardItem* pItem = GAME_GetMultiboardItem(dwItemId);

		if(pItem)
			GAME_SetMultiboardItemValue(pItem, NULL, szValue);
	}

	GAME_ReleaseMultiboardItemId(dwItemId);
}

VOID cMultiboard::SetItemWidth(float fWidth, DWORD dwColumn, DWORD dwRow)
{
	if(!this->dwId)
		return;

	DWORD dwItemId = GAME_GetMultiboardItemId(this->dwId, dwColumn, dwRow);

	if(dwItemId)
		GAME_SetMultiboardItemWidth(dwItemId, &fWidth);

	GAME_ReleaseMultiboardItemId(dwItemId);
}

VOID cMultiboard::Display(BOOL bValue)
{
	if(this->dwId)
		GAME_DisplayMultiboard(this->dwId, bValue);
}

VOID cMultiboard::Minimize(BOOL bValue)
{
	if(this->dwId)
	{
		Multiboard* pBoard = GAME_GetMultiboard(this->dwId);

		GAME_SetMultiboardMinimized(pBoard, NULL, bValue);
	}
}

BOOL cMultiboard::IsMultiboardDisplayed()
{
	if(this->dwId)
		return GAME_IsMultiboardDisplayed(this->dwId);

	return FALSE;
}

BOOL cMultiboard::IsMultiboardMinimized()
{
	if(this->dwId)
		return GAME_IsMultiboardMinimized(this->dwId);

	return FALSE;
}

VOID cMultiboard::Clear()
{
	if(this->dwId)
		GAME_ClearMultiboard(this->dwId);
}

CHAR* cMultiboard::GetTitleText()
{
	if(this->dwId)
	{
		Multiboard* pBoard = GAME_GetMultiboard(this->dwId);

		if(pBoard)
			return GAME_GetMultiboardTitleText(pBoard);
	}
	
	return NULL;
}

VOID cMultiboard::SetMultiboardTitleColor(DWORD dwColor)
{
	if(this->dwId)
	{
		Multiboard* pBoard = GAME_GetMultiboard(this->dwId);

		if(pBoard)
			GAME_SetMultiboardTitleColor(pBoard, NULL, dwColor);
	}
}

DWORD cMultiboard::GetMultiboardRowCount()
{
	if(this->dwId)
		return GAME_GetMultiboardRowCount(this->dwId);

	return NULL;
}

DWORD cMultiboard::GetMultiboardColumnCount()
{
	if(this->dwId)
		return GAME_GetMultiboardColumnCount(this->dwId);

	return NULL;
}

VOID cMultiboard::SetItemColor(DWORD dwColor, DWORD dwColumn, DWORD dwRow)
{
	if(!this->dwId)
		return;

	DWORD dwItemId = GAME_GetMultiboardItemId(this->dwId, dwColumn, dwRow);

	if(dwItemId)
	{
		MultiboardItem* pItem = GAME_GetMultiboardItem(dwItemId);

		if(pItem)
			GAME_SetMultiboardItemColor(pItem, NULL, dwColor);
	}

	GAME_ReleaseMultiboardItemId(dwItemId);
}